package com.koron.order.maintain.controller;

import com.koron.bean.base.Response;
import com.koron.order.common.bean.po.OrderInstructionBean;
import com.koron.order.common.bean.po.OrderSignBean;
import com.koron.order.common.controller.OrderExecuteController;
import com.koron.order.maintain.bean.entity.*;
import com.koron.order.maintain.bean.vo.MaintainEquipmentVo;
import com.koron.order.maintain.bean.vo.MaintainExecuteVo;
import com.koron.order.maintain.bean.vo.MaintainItemVo;
import com.koron.order.maintain.bean.vo.OperateFormVo;
import com.koron.order.maintain.service.MaintainExecuteService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.koron.ebs.mybatis.ADOConnection;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;

import java.util.List;

/**
 * @ClassName MaintainExcuteController
 * @description
 * @Author zhouj
 * @Date 2021/9/16 8:51
 */
@Api(tags = "日常维护工单-执行中信息")
@RestController
@RequestMapping("/maintain/execute/")
public class MaintainExecuteController extends OrderExecuteController {

    @Autowired
    private MaintainExecuteService maintainExecuteService;

    @ApiIgnore
    @ApiOperation(value = "新增或更新")
    @PostMapping("insertOrUpdate")
    public Response<Integer> insertOrUpdate(@RequestBody MaintainExecuteVo maintainExecuteVo) {
        return Response.ok(ADOConnection.runTask(getCurrDs(), maintainExecuteService, "insertOrUpdate", Integer.class, maintainExecuteVo));
    }

    @ApiOperation(value = "根据id删除 ")
    @DeleteMapping("deleteById")
    public Response<Integer> deleteById(String id) {
        return Response.ok(ADOConnection.runTask(getCurrDs(), maintainExecuteService, "deleteById", Integer.class, id));
    }

    @ApiOperation(value = "根据工单Id查询作业表单信息 ")
    @GetMapping("queryByOrderId")
    public Response<OperateFormVo> queryById(String orderId) {
        return Response.ok(ADOConnection.runTask(getCurrDs(), maintainExecuteService, "queryByOrderId", OperateFormVo.class, orderId));
    }

    @ApiOperation(value = "根据工单Id查询作业表单-作业准备信息 ")
    @GetMapping("queryReadyByOrderId")
    public Response<List<MaintainReadyPo>> queryReadyByOrderId(String orderId) {
        return Response.ok(ADOConnection.runTask(getCurrDs(), maintainExecuteService, "queryReadyByOrderId", List.class, orderId));
    }

    @ApiOperation(value = "根据工单Id查询作业表单-作业指导书信息 ")
    @GetMapping("queryInstructionByOrderId")
    public Response<List<OrderInstructionBean>> queryInstructionByOrderId(String orderId) {
        return Response.ok(ADOConnection.runTask(getCurrDs(), maintainExecuteService, "queryInstructionByOrderId", List.class, orderId));
    }

    @ApiOperation(value = "根据工单Id查询作业表单-设备以及下属项目列表信息 ")
    @GetMapping("queryEquipmentVoByOrderId")
    public Response<List<MaintainEquipmentVo>> queryEquipmentVoByOrderId(String orderId,String maintainEquipmentId) {
        return Response.ok(ADOConnection.runTask(getCurrDs(), maintainExecuteService, "queryEquipmentVoByOrderId", List.class, orderId,maintainEquipmentId));
    }

    @ApiOperation(value = "根据工单Id查询作业表单-设备信息列表信息 ")
    @GetMapping("queryEquipmentBeanListByOrderId")
    public Response<List<MaintainEquipmentPo>> queryEquipmentBeanListByOrderId(String orderId) {
        return Response.ok(ADOConnection.runTask(getCurrDs(), maintainExecuteService, "queryEquipmentBeanListByOrderId", List.class, orderId));
    }

    @ApiOperation(value = "根据工单Id,设备id查询作业表单-设备下项目信息列表信息 ")
    @GetMapping("queryMaintainItemByEqId")
    public Response<List<MaintainItemVo>> queryMaintainItemByEqId(String orderId, String maintainEquipmentId) {
        return Response.ok(ADOConnection.runTask(getCurrDs(), maintainExecuteService, "queryMaintainItemByEqId", List.class, orderId, maintainEquipmentId));
    }

    @ApiOperation(value = "新增或更新作业表单信息")
    @PutMapping("insertOrUpdateOperateForm")
    public Response<String> insertOrUpdateOperateForm(@RequestBody OperateFormVo operateFormVo) {
        return Response.ok(ADOConnection.runTask(getCurrDs(), maintainExecuteService, "insertOrUpdateOperateForm", String.class, operateFormVo));
    }

    @ApiOperation(value = "更新作业表单-作业准备信息")
    @PutMapping("updateMaintainReady")
    public Response<Integer> updateMaintainReady(@RequestBody MaintainReadyPo maintainReadyPo) {
        return Response.ok(ADOConnection.runTask(getCurrDs(), maintainExecuteService, "updateMaintainReady", Integer.class, maintainReadyPo));
    }


    @ApiOperation(value = "批量更新作业表单-作业准备信息")
    @PutMapping("updateBatchMaintainReady")
    public Response<Integer> updateBatchMaintainReady(@RequestBody List<MaintainReadyPo> maintainReadyPos) {
        return Response.ok(ADOConnection.runTask(getCurrDs(), maintainExecuteService, "updateBatchMaintainReady", Integer.class, maintainReadyPos));
    }


    @ApiOperation(value = "更新作业表单-作业过程信息")
    @PutMapping("updateMaintainItemVo")
    public Response<Integer> updateMaintainItemVo(@RequestBody MaintainItemVo maintainItemVo) {
        return Response.ok(ADOConnection.runTask(getCurrDs(), maintainExecuteService, "updateMaintainItemVo", Integer.class, maintainItemVo));
    }

    @ApiOperation(value = "更新作业表单-作业过程-设备信息")
    @PutMapping("updateMaintainEquipment")
    public Response<Integer> updateMaintainEquipment(@RequestBody MaintainEquipmentPo maintainEquipmentPo) {
        return Response.ok(ADOConnection.runTask(getCurrDs(), maintainExecuteService, "updateMaintainEquipment", Integer.class, maintainEquipmentPo));
    }

    @ApiOperation(value = "更新作业表单-作业过程-项目信息")
    @PutMapping("updateMaintainItem")
    public Response<Integer> updateMaintainItem(@RequestBody MaintainItemPo maintainItemPo) {
        return Response.ok(ADOConnection.runTask(getCurrDs(), maintainExecuteService, "updateMaintainItem", Integer.class, maintainItemPo));
    }

    @ApiOperation(value = "更新作业表单-作业过程-项目信息")
    @PutMapping("updateBatchMaintainItem")
    public Response<Integer> updateBatchMaintainItem(@RequestBody List<MaintainItemPo> maintainItemPos) {
        return Response.ok(ADOConnection.runTask(getCurrDs(), maintainExecuteService, "updateBatchMaintainItem", Integer.class, maintainItemPos));
    }

    @ApiOperation(value = "更新作业表单-作业过程-参数项值信息")
    @PutMapping("updateMaintainItemParams")
    public Response<Integer> updateMaintainItemParams(@RequestBody MaintainItemParamsPo itemParamsBean) {
        return Response.ok(ADOConnection.runTask(getCurrDs(), maintainExecuteService, "updateMaintainItemParams", Integer.class, itemParamsBean));
    }

    @ApiOperation(value = "更新作业表单-作业过程-签名信息")
    @PutMapping("insertOrderSignInfo")
    public Response<Integer> insertOrderSignInfo(@RequestBody OrderSignBean orderSignBean) {
        return Response.ok(ADOConnection.runTask(getCurrDs(), maintainExecuteService, "insertOrderSignInfo", Integer.class, orderSignBean));
    }

    @ApiOperation(value = "更新作业表单-作业表单-主表信息")
    @PutMapping("updateMaintainInfo")
    public Response<Integer> updateMaintainInfo(@RequestBody MaintainPo maintainPo) {
        return Response.ok(ADOConnection.runTask(getCurrDs(), maintainExecuteService, "updateMaintainInfo", Integer.class, maintainPo));
    }

    @ApiOperation(value = "作业标准生成项目及参数项列表")
    @PutMapping("generateStand")
    public Response<Boolean> generateStand(String orderId) {
        return Response.ok(ADOConnection.runTask(getCurrDs(), maintainExecuteService, "generateStand", Boolean.class, orderId));
    }

}
